package com.gator.desig_mode.dicorator.test;

/**
 * @author 何章怀晓 hezhanghuaixiao
 * @version V1.0
 * @desc
 */
public class CakeDecorator extends CakeComponent {

  private CakeComponent cakeComponent;

  public CakeDecorator(CakeComponent cakeComponent) {
    this.cakeComponent = cakeComponent;
  }


  //计算价格  当前装饰器价格+ 之前主体价格（上次装饰器价格+主体价格）
  @Override
  public float cost() {
    return super.getPrice() + cakeComponent.cost();
  }


  //每次装饰都是对之前主体的嵌套
  @Override
  public String getDesc() {
    return super.getPrice() + " -- " + super.getDesc() + " && " + cakeComponent.getDesc();
  }
}
